﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OrganizationName.Common
{
    public class Tree<T> : UniqueIdProvider where T : Tree<T>
    {
        protected T _Parent;
        private List<T> _Children = new List<T>();

        public T Parent
        {
            get
            {
                return _Parent;
            }
            protected set
            {
                _Parent = value;
            }
        }

        public ICollection<T> Children
        {
            get
            {

                return _Children;
            }
        }

        public T Root
        {
            get
            {
                return _Parent != null ? _Parent.Root : this as T;
            }
        }
    }
}
